package com.itheima.mall.web.oms;

import com.itheima.mall.pojo.oms.OmsOrderReturnReason;

import com.itheima.mall.service.oms.OrderReturnReasonService;
import com.itheima.mall.vo.PageResult;
import com.itheima.mall.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("returnReason")
public class OrderReturnReasonController {
    @Autowired
    private OrderReturnReasonService orderReturnReasonService;

    @PostMapping("/create")
    public R createReason(@RequestBody OmsOrderReturnReason omsOrderReturnReason){
        orderReturnReasonService.createReason(omsOrderReturnReason);
        return R.succeed(null,null);
    }

    @PostMapping("delete")
    public R deleteReason(@RequestParam Integer[]ids){
        orderReturnReasonService.deleteReason(ids);
        return R.succeed(null,null);
    }

    @GetMapping("list")
    public R findReason(@RequestParam Integer pageNum,@RequestParam Integer pageSize){
        PageResult pageResult = orderReturnReasonService.findReason(pageNum,pageSize);
        return R.succeed(pageResult,null);
    }

    @PostMapping("/update/status")
    public R updateStatus(@RequestParam Integer[]ids,@RequestParam Integer status){
        orderReturnReasonService.updateStatus(ids,status);
        return R.succeed(null,null);
    }

    @PostMapping("/update/{id}")
    public R updateReason(@RequestBody OmsOrderReturnReason omsOrderReturnReason,@PathVariable Integer id){
        orderReturnReasonService.updateReason(omsOrderReturnReason,id);
        return R.succeed(null,null);
    }

    @GetMapping("/{id}")
    public R getOneReason(@PathVariable Integer id){
        OmsOrderReturnReason omsOrderReturnReason = orderReturnReasonService.getOneReason(id);
        return R.succeed(omsOrderReturnReason,null);
    }






}
